<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>密码框效果</title>
    <script>
        window.onload = function() {
            var ipt = document.getElementById("ipt")
            var message = document.getElementById("message")
            ipt.onblur = function() {
                if (ipt.value.length >= 6 && ipt.value.length <= 16) {
                    message.innerHTML = '您输入的正确'
                    message.style.color = 'green'
                } else {
                    message.innerHTML = '您输入的位数不对要求6-16位'
                    message.style.color = 'red'
                }
            }
        }
    </script>
</head>

<body>
    <input id="ipt" type="password">
    <p id="message">请输入6-16位密码</p>

</body>

</html>